//
//  YYJLAnswerSheetController.m
//  YuanyangJinlou
//
//  Created by mac004 on 2017/1/9.
//  Copyright © 2017年 suli19910309@qq.com. All rights reserved.
//

#import "YYJLAnswerSheetController.h"
#import "YYJLEvalutionReportController.h"
@interface YYJLAnswerSheetController ()
{
    UIScrollView * _scrollview;
    UIView  * blureyView;//覆盖层
    UIView  * tipView;//提示框
}
@end

@implementation YYJLAnswerSheetController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setTitleView:@"答题卡"];
    [self setBackItem];
    [self creatUI];
    
}

-(void)creatUI{
    UILabel * title=[MyControl createLabelWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, 44*PER_HEIGHT) Font:15 Text:@"2016年11月考试题" Color:BLACK_COLOR];
    title.textAlignment=NSTextAlignmentCenter;
    title.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:title];
    
    _scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0,title.bottom,SCREEN_WIDTH , SCREEN_HEIGHT-64-title.height)];
    _scrollview.backgroundColor=[UIColor clearColor];
    [self.view addSubview:_scrollview];
    
    UIImage * IMG =[UIImage imageNamed:@"ico_timu_sel"];//36*43
    
    for (int i =0 ; i<10; i++) {
        int j=i/5;
        int x=i%5;
       
        
        UIImageView * img=[[UIImageView alloc]initWithFrame:CGRectMake(28*PER_WIDTH+x*70*PER_WIDTH, 20*PER_HEIGHT+j*63*PER_HEIGHT, 36*PER_WIDTH, 43*PER_HEIGHT)];
        img.tag=100+i;
        img.image=IMG;
        [_scrollview addSubview:img];
        
        UILabel * lab=[MyControl createLabelWithFrame:CGRectMake(0, 15*PER_HEIGHT, img.width, 20*PER_HEIGHT) Font:20 Text:[NSString stringWithFormat:@"%d",i+1] Color:UIColorFromHex(0xdea556)];
        lab.font=[UIFont fontWithName:HLT size:20];
        lab.font=[UIFont systemFontOfSize:20*PER_HEIGHT];
        lab.textAlignment=NSTextAlignmentCenter;
        [img addSubview:lab];
        
    }
    
    
    UIButton * btn=[MyControl createButtonWithFrame:CGRectMake(17.5*PER_WIDTH, SCREEN_HEIGHT-56*PER_HEIGHT, 340*PER_WIDTH, 36*PER_HEIGHT) ImageName:@"" Target:self Action:@selector(commitTest) Title:@"交卷并查看结果"];
    [btn setTitleColor:WHITE_COLOR forState:0];
    btn.layer.cornerRadius=btn.height/2;
    btn.backgroundColor=TINK_COLOR;
    btn.titleLabel.font=[UIFont systemFontOfSize:15*PER_HEIGHT];
    [self.view addSubview:btn];
    
    blureyView=[[UIView alloc]initWithFrame:self.view.bounds];
    blureyView.backgroundColor=[UIColorFromHex(0x000000) colorWithAlphaComponent:.4];
    [self.view addSubview:blureyView];
    blureyView.hidden=YES;
    [self.view sendSubviewToBack:blureyView];
    

}

-(void)addTipView{
    
    blureyView.hidden=NO;
    [self.view bringSubviewToFront:blureyView];
    tipView =[[UIView alloc]initWithFrame:CGRectMake(37*PER_WIDTH, 240*PER_HEIGHT, SCREEN_WIDTH-74*PER_WIDTH, 175*PER_HEIGHT)];
    tipView.layer.cornerRadius=10;
    tipView.layer.masksToBounds=YES;
    tipView.backgroundColor=[UIColor whiteColor];
    [blureyView addSubview:tipView];
    
    UILabel * tipLb=[MyControl createLabelWithFrame:CGRectMake(0, 25*PER_HEIGHT, tipView.width, 16*PER_HEIGHT) Font:16 Text:@"提示" Color:TINK_COLOR];
    tipLb.textAlignment=NSTextAlignmentCenter;
    [tipView addSubview:tipLb];
    
    UILabel * sureLb=[MyControl createLabelWithFrame:CGRectMake(0, tipLb.bottom+20*PER_HEIGHT, tipView.width, 15*PER_HEIGHT) Font:15 Text:@"你还有两道题未答,确认交卷吗?" Color:BLACK_COLOR];
    sureLb.textAlignment=NSTextAlignmentCenter;
    [tipView addSubview:sureLb];
    
    //取消按钮
    UIButton * cancelBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    cancelBtn.frame=CGRectMake(25*PER_WIDTH, tipView.height-61*PER_HEIGHT, 120*PER_WIDTH, 36*PER_WIDTH);
    cancelBtn.layer.cornerRadius=cancelBtn.height/2;
    cancelBtn.layer.borderColor=TINK_COLOR.CGColor;
    cancelBtn.layer.borderWidth=1;
    cancelBtn.titleLabel.font=[UIFont fontWithName:HSGBW3 size:16];
    cancelBtn.titleLabel.font=[UIFont systemFontOfSize:16*PER_HEIGHT];
    [cancelBtn setTitle:@"取消" forState:0];
    [cancelBtn setTitleColor:UIColorFromHex(0xa21b18) forState:0];
    [cancelBtn addTarget:self action:@selector(cancelBtn) forControlEvents:UIControlEventTouchUpInside];
    [tipView addSubview:cancelBtn];
    
    // 确定按钮
    UIButton * sureBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    sureBtn.frame=CGRectMake(cancelBtn.right+11*PER_WIDTH, tipView.height-61*PER_HEIGHT, 120*PER_WIDTH, 36*PER_WIDTH);
    sureBtn.layer.cornerRadius=cancelBtn.height/2;
    //    sureBtn.layer.borderColor=TINK_COLOR.CGColor;
    //    sureBtn.layer.borderWidth=1;
    sureBtn.backgroundColor=TINK_COLOR;
    sureBtn.titleLabel.font=[UIFont fontWithName:HSGBW3 size:16];
    sureBtn.titleLabel.font=[UIFont systemFontOfSize:16*PER_HEIGHT];
    
    [sureBtn setTitle:@"确定" forState:0];
 
    [sureBtn setTitleColor:WHITE_COLOR forState:0];
    [sureBtn addTarget:self action:@selector(sureBtn) forControlEvents:UIControlEventTouchUpInside];
    [tipView addSubview:sureBtn];
    
    
}
#pragma mark--退出考试
-(void)cancelBtn{
    [tipView removeFromSuperview];
    blureyView.hidden=YES;
    [self.view sendSubviewToBack:blureyView];
}
-(void)sureBtn
{
    [tipView removeFromSuperview];
    blureyView.hidden=YES;
    [self.view sendSubviewToBack:blureyView];
    YYJLEvalutionReportController * report=[[YYJLEvalutionReportController alloc]init];
    [self.navigationController pushViewController: report animated:YES];

}

-(void)commitTest{
    
    [self addTipView];
    }
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
